define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/user/consume_log',
                    table: 'user_consume_log',
                }
            });

            var table = $("#table");
            
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                commonSearch: false,
                columns: [
                    [
                        {field: 'id', title: __('Id')},
                        {field: 'type', title: __('Type'), searchList: {
                            "vip": __('会员'),
                            "goods": __('商品'),
                            "travel": __('文旅'),
                            "service": __('服务'),
                            "withdraw": __('提现'),
                            "refund": __('退款'),
                        }, formatter: Table.api.formatter.normal},
                        {field: 'target_title', title: __('消费项目'), operate: 'LIKE'},
                        {field: 'amount', title: __('金额'), operate: false, formatter: function(value) {
                            return value > 0 ? '<span class="text-success">+' + value + '</span>' : '<span class="text-danger">' + value + '</span>';
                        }},
                        {field: 'createtime', title: __('消费时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        }
    };
    return Controller;
});